﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
//using LTP.Accounts.Bus;
namespace xxxy.Web.teamInfo
{
    public partial class Modify : Page
    {       

        		protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
				{
					int teamID=(Convert.ToInt32(Request.Params["id"]));
					ShowInfo(teamID);
				}
			}
		}
			
	private void ShowInfo(int teamID)
	{
		xxxy.BLL.teamInfo bll=new xxxy.BLL.teamInfo();
		xxxy.Model.teamInfo model=bll.GetModel(teamID);
		this.lblteamID.Text=model.teamID.ToString();
		this.txttDataName.Text=model.tDataName;
		this.txttHonorLevel.Text=model.tHonorLevel;
		this.txttIssuingTime.Text=model.tIssuingTime.ToString();
		this.txttUploadName.Text=model.tUploadName.ToString();
		this.txttUploadTime.Text=model.tUploadTime.ToString();
		this.txttDepartment.Text=model.tDepartment;
		this.txttHsot.Text=model.tHsot;
		this.txttParticipator.Text=model.tParticipator;
		this.txttGrade.Text=model.tGrade;
		this.txttAddress.Text=model.tAddress;
		this.txttRemarks.Text=model.tRemarks;
		this.txttAttachment.Text=model.tAttachment;
		this.txttStation.Text=model.tStation.ToString();

	}

		public void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(this.txttDataName.Text.Trim().Length==0)
			{
				strErr+="资料名称不能为空！\\n";	
			}
			if(this.txttHonorLevel.Text.Trim().Length==0)
			{
				strErr+="荣誉等级不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txttIssuingTime.Text))
			{
				strErr+="发证时间格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txttUploadName.Text))
			{
				strErr+="上传人格式错误！\\n";	
			}
			if(!PageValidate.IsDateTime(txttUploadTime.Text))
			{
				strErr+="上传时间格式错误！\\n";	
			}
			if(this.txttDepartment.Text.Trim().Length==0)
			{
				strErr+="发证机构不能为空！\\n";	
			}
			if(this.txttHsot.Text.Trim().Length==0)
			{
				strErr+="主持人不能为空！\\n";	
			}
			if(this.txttParticipator.Text.Trim().Length==0)
			{
				strErr+="参与人不能为空！\\n";	
			}
			if(this.txttGrade.Text.Trim().Length==0)
			{
				strErr+="等级不能为空！\\n";	
			}
			if(this.txttAddress.Text.Trim().Length==0)
			{
				strErr+="存放地址不能为空！\\n";	
			}
			if(this.txttRemarks.Text.Trim().Length==0)
			{
				strErr+="备注不能为空！\\n";	
			}
			if(this.txttAttachment.Text.Trim().Length==0)
			{
				strErr+="附件不能为空！\\n";	
			}
			if(!PageValidate.IsNumber(txttStation.Text))
			{
				strErr+="审核状态格式错误！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			int teamID=int.Parse(this.lblteamID.Text);
			string tDataName=this.txttDataName.Text;
			string tHonorLevel=this.txttHonorLevel.Text;
			DateTime tIssuingTime=DateTime.Parse(this.txttIssuingTime.Text);
			int tUploadName=int.Parse(this.txttUploadName.Text);
			DateTime tUploadTime=DateTime.Parse(this.txttUploadTime.Text);
			string tDepartment=this.txttDepartment.Text;
			string tHsot=this.txttHsot.Text;
			string tParticipator=this.txttParticipator.Text;
			string tGrade=this.txttGrade.Text;
			string tAddress=this.txttAddress.Text;
			string tRemarks=this.txttRemarks.Text;
			string tAttachment=this.txttAttachment.Text;
			int tStation=int.Parse(this.txttStation.Text);


			xxxy.Model.teamInfo model=new xxxy.Model.teamInfo();
			model.teamID=teamID;
			model.tDataName=tDataName;
			model.tHonorLevel=tHonorLevel;
			model.tIssuingTime=tIssuingTime;
			model.tUploadName=tUploadName;
			model.tUploadTime=tUploadTime;
			model.tDepartment=tDepartment;
			model.tHsot=tHsot;
			model.tParticipator=tParticipator;
			model.tGrade=tGrade;
			model.tAddress=tAddress;
			model.tRemarks=tRemarks;
			model.tAttachment=tAttachment;
			model.tStation=tStation;

			xxxy.BLL.teamInfo bll=new xxxy.BLL.teamInfo();
			bll.Update(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","list.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
